<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head>
    <th:block th:include="include :: header('公共代码详情')" />
</head>
<body>
<div class="container-div">
    <input name="psId" autocomplete="off" id="psId"  class="form-control" type="hidden" th:value="${ggDmInfo.id}" >
    <div class="row">
        <div th:include="biz/ggDm/include::detail-header"></div>
    </div>
</div>
<div th:include="include::footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "biz/ggDm";
    var editFlag = [[${@permission.hasPermi('biz:ggDm:edit')}]];

    $(function() {
        var options = {
            id: "unit-table",
            url: prefix + "/list/"+[[${ggDmInfo.id}]],
            createUrl: prefix + "/add",
            removeUrl: prefix + "/remove",
            modalName: "公共代码",
            columns: [{
                checkbox: true
            },
                {
                    field : 'id',
                    title : 'ID'
                },
                {
                    field : 'dmmc',
                    title : '代码名称'
                },
                {
                    field : 'dm',
                    title : '代码'
                },
                {
                    field : 'dmtype',
                    title : '代码类型'
                },{
                    field : 'val',
                    title : '字段值'
                },
                {
                    field: 'isDeleted',
                    title: '删除标志',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var isDeleted = '';
                        switch(row.isDeleted){
                            case '1':
                                isDeleted='已删除';
                                break;
                            default:
                                isDeleted='未删除';
                        }
                        return isDeleted;
                    }
                },
                {
                    field: 'isValid',
                    title: '是否有效',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detailTab(\'' + row.id + '\')"><i class="fa fa-file-text"></i>查看详情</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function statusTools(row) {
        if (row.isValid == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
        }
    }

    function disable(id) {
        $.modal.confirm("确认要停用吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
        })
    }

    function enable(id) {
        $.modal.confirm("确认要启用吗？", function() {
            $.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
        })
    }

</script>
</body>
</html>
